from woniusales_ui_test_3.page.basepage import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import random
import time
class GoodsPage(BasePage):
    queryBatch_locator=(By.XPATH,'//input[@onclick="queryBatch()"]')
    uploadBatchFile_locator=(By.XPATH,'//input[@onclick="uploadBatchFile()"]')
    check_list_locator = (By.XPATH, '//a[@target="_blank"]')  # 查看清单
    batchname_locator = (By.XPATH, '//*[@id="batchname"]')  # 批次名输入
    now = 'GB' + time.strftime('%Y%m%d%H%M')
    batchfile_locator = (By.XPATH, '//*[@id="batchfile"]')
    file_path =  r'C:\Users\Administrator\Desktop\Test79\01-课程资源\销售出库单-20171020-Test.xls'
    opts_locator = (By.XPATH, '//*[@id="batchnamelist"]/option')

    change_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[1]')  # 修改
    unique_locator = (By.XPATH, '//tbody[@id="batchinfo"]/tr[1]/td[2]')  # 唯一编号
    del_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[2]')  # 删除
    ok_locator = (By.XPATH, '//button[@data-bb-handler="ok"]')
    # del_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[2]')
    # del_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[2]')
    # del_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[2]')
    # del_locator = (By.XPATH, '//*[@id="batchinfo"]/tr[1]/td[11]/a[2]')


    def click_checkList(self):  # 点击查看清单
        self.click(self.check_list_locator)
    def click_queryBatch(self):  # 点击确认查询
        self.click(self.queryBatch_locator)
    def click_uploadBatchFile(self):  # 点击上传文件
        self.click(self.uploadBatchFile_locator)
    def input_batchname(self):  # 输入批次名
        # self.input_text(self.batchname_locator, (Keys.CONTROL, 'a'))
        self.input_text(self.batchname_locator, self.now)
    def upload_file(self):  # 输入文件
        self.input_text(self.batchfile_locator, self.file_path)
        self.input_text(self.batchfile_locator,self.file_path)
    def click_opts(self):  # 随机选择批次
        self.rand_click(self.opts_locator)
    def click_change(self):  # 点击修改
        self.click(self.change_locator)
    def get_unique(self):  # 获取唯一编号
        return self.get_text(self.unique_locator)
    def click_del(self):  # 点击删除
        self.click(self.del_locator)
    def click_ok(self):  # 点击确定弹窗
        self.click(self.ok_locator)



if __name__ == '__main__':
    print(GoodsPage().opts_locator)